<template>
    <view class="content">
        <Collapse @finishDropClicks="changesaixuan"/>
        <listBox :list="goodslist"/>
    </view>
</template>
<script>
import listBox from "@/pages/components/list-box.vue";
import Collapse from "@/components/Collapse";

export default {
    name: 'index',
    components: {
        listBox,
        Collapse,

    },
    data() {
        return {
			cid:0,
			goodslist:[]
        }
    },
   onLoad(e){
   	if(e.cid){
   		this.cid = e.cid
   	}
   },
   onShow() {
   	this.page = 1
   	this.getlist()
   },
   onReachBottom() {
     if (this.total > this.page) {
       this.page++;
       this.getlist();
     }
   },
   methods: {
   	change(e){
   		console.log(e)
   		this.getlist()
   	},
   	changesaixuan(e) {
   		console.log('-------------')
   	  this.zonghe = e[0] ? e[0] : 0;
   	  this.new = e[1] ? e[1] : 0;
   	  this.price = e[2] ? e[2] : 0;
   	  this.xiaoliang = e[3] ? e[3] : 0;
   	  this.page = 1;
   	  this.getlist();
   	},
   	getlist() {
   	  var that = this;
   	  this.$.ajax(
   	    1,
   	    "POST",
   	    "index/getgoodslist",
   	    {
   	      page: this.page,
		  cid:this.cid,
		  zonghe: this.zonghe,
		  new: this.new,
		  price: this.price,
		  tuijian: this.tuijian,
		  cid: this.cid,
		  xiaoliang: this.xiaoliang,
   	    },
   	    (res) => {
   	      if (res.code == 1) {
   	        console.log(res.data.list);
   	        if (that.page == 1) {
   	          that.goodslist = [];
   	        }
   	        that.goodslist = [...res.data.list, ...that.goodslist];
   	      }
   	    }
   	  );
   	},
       custom(){
           uni.navigateBack()
       },
       go(){
   		uni.navigateBack()
       },
       fichangenishDropClicks(e){
   
           this.$emit('changesaixuan', e)
       }
   },
    created() {

    },
    mounted() {

    },
}
</script>
<style scoped>
.content{
    background-color: #fff;
    padding:10rpx;
}
</style>

